<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>Array2Table Basic Demo</title>
<style>


/*3 different rotypes whith 3 different colors*/
.att .rowtype-1 {background:#eeffff;}
.att .rowtype-2{background:#ffffee;}
.att .rowtype-3 {background:#ffeeff;}

/*special colors for footer anf header*/
.att .hrow {background:#ffdddd;}
.att .frow {background:#eeeeee;}

/*Last column*/
.att .rcol-1 {border:1px solid red;}

/*first column*/
.att .col-1 {font-weight:bold; color:green;}

/*colors for different header columntypes*/
.att .hcoltype-1 {}
.att .hcoltype-2{background:#ddddff;}
.att .hcoltype-3{background:#ddffdd;}

/*colors for different footer columntypes*/
.att .fcoltype-1 {}
.att .fcoltype-2{background:#dddddd;}
.att .fcoltype-3{background:#cccccc;}

/*all header colums get align right*/
.att .hcol {text-align:right;}

/*one field at a special position gets a special threatment*/
.att .row-3 .col-3 {border:3px dotted green;}

</style>
</head>

<body>
<?php






//We can process some different types of arrays but all 2 dimensional 

//One Dataarray whith Keys that can be used as footer or header.
$aData = array( 
               array("Name" => "rose",   "Price" => 1.25 ,  "Number" => 15,  "Description" => "sometext", "Letter" => "A", "Number" => "1"),
               array("Name" => "daisy",  "Price" => 0.75 ,  "Number" =>  25, "Description" => "moretext", "Letter" => "B", "Number" => "2"),
               array("Name" => "orchid", "Price" =>  1.15 , "Number" =>  7,  "Description" => "evenmore", "Letter" => "C", "Number" => "3"), 
               array("Name" => "rose2",  "Price" => 1.25 ,  "Number" => 15,  "Description" => "sometext", "Letter" => "D", "Number" => "4"),
               array("Name" => "daisy3", "Price" => 0.75 ,  "Number" =>  25, "Description" => "moretext", "Letter" => "e", "Number" => "5"),
               array("Name" => "orchid4","Price" =>  1.15 , "Number" =>  7,  "Description" => "evenmore", "Letter" => "F", "Number" => "6"),
               array("Name" => "rose3",  "Price" => 1.25 ,  "Number" => 15,  "Description" => "sometext", "Letter" => "D", "Number" => "7"),
               array("Name" => "daisy4", "Price" => 0.75 ,  "Number" =>  25, "Description" => "moretext", "Letter" => "e", "Number" => "8"),
               array("Name" => "orchid5","Price" =>  1.15 , "Number" =>  7,  "Description" => "evenmore", "Letter" => "F", "Number" => "9") 
             ); 
             
     

// include the Script
include ("classes/arraytotable.php");

// create new tableobject
$oAtt=new ArrayToTable();

// set the main Data Array
$oAtt->aData =$aData;

// Fetch header and footer from keys of an associative array.
$oAtt->sHeadAutoFetch = "keys";
$oAtt->sFootAutoFetch = "keys";

// we can add some extra attributes to the table
$oAtt->sTableExtra ='border="0" cellpadding="3" cellspacing="3"';

// how many types of cycling rowtypes and coltypes shall we create
$oAtt->iMaxRowTypes=3;
$oAtt->iMaxColTypes=3;

// set Caption
$oAtt->sCaption="Hallo Überschrift";


//partially override template
// the override array is applied after a default tamplate is loaded 
// so it always overrides even an externally loaded template
// in addition this schows the colgroup fearure
$oAtt->aTplOverride['TabColgroup']='
\t\t<colgroup>
\t\t\t<col width="80">
\t\t\t<col width="100">
\t\t\t<col width="320">
\t\t\t<col width="120">
\t\t</colgroup>
';

// Do the actual job
echo ($oAtt->Create());



// for debugging you can output the internal arrays if you like 
echo "<pre>";
// all errors als array
//print_r($oAtt->aError);

//printr template contains html that needs to be escaped before output
//$inputarray=$oAtt->aTpl;
//array_walk_recursive($inputarray, function(&$v) { $v = htmlspecialchars($v); });
//print_r($inputarray);

// footer and or header
//print_r($oAtt->aHeader);
//print_r($oAtt->aFooter);

// data array after processing it (ie. stripped header/footer data)
//print_r($oAtt->aData);
echo "</pre>";


?>
</body>
</html>